<?php
/**
 * Login_Model_Registred
 * registred model
 *
 * @author Adrian Stolarski
 */
class Login_Model_Registred implements Login_Data_Mainable, Login_Model_Checkable, 
        Login_Model_Setable {
    
    public $add_user_object;
    /**
     *
     * @var type $registry_redirect
     * registry reirect handler
     */
    public $regstry_redirect;
    /**
     *
     * @var type $get_data
     * get data handler
     */
    public $get_data;
    /**
     *
     * @var type $message
     * message handler
     */
    public $message;
    /**
     *
     * @var type $set_user_data
     * set user data
     */
    public $set_user_data;
    
    public function __construct() {
        $this->set_user_data = new Login_Data_Registred;;
    }
    public function main(array $variables = null) {
        //$this->check_data($variables['post']);
        //$this->select_action($variables['post']);
        $variables['post']['value'] = $this->set_data($variables['post']);
        $this->check_data($variables['post']);
    }
    
    
    /**
     * set_data()
     * set registred data
     * 
     * @param array $variables
     */
    public function set_data(array $variables = null) {
        //var_dump($variables);
        //die();
        return $this->set_user_data->main($variables);
    }

    public function check_data(array $variables = null) {
        //var_dump($variables);
        //die();
        if($variables['value'] == -1){
            $this->message = new Login_Data_Javascriptmessage;
            $this->message->message(null);
            $this->regstry_redirect = new Login_Data_Loginredirect;
            $this->regstry_redirect->main($variables);
        }
        else {
            //var_dump($variables);
           // die();
            $this->add_user_object = new Login_Data_Setuserdata;
            $this->add_user_object->main($variables);
            //var_dump($variables);
            //die();
            $this->set_user_data->send_email($variables);
            $this->set_user_data->message($variables['user_email']);
        }
    }

}
